public class Object01
{
    public static void main(String[] args)
    {
        // 示例1：根据条件返回不同的字符串对象
        String str1 = "Hello";
        String str2 = "World";
        String result = (str1.length() > str2.length()) ? str1 : str2;
        System.out.println("The longer string is: " + result);

        // 示例2：根据条件返回不同的对象引用
        Person person1 = new Person("Alice", 30);
        Person person2 = new Person("Bob", 25);
        Person olderPerson = (person1.getAge() > person2.getAge()) ? person1 : person2;
        System.out.println("The older person is: " + olderPerson.getName());


    }
}

class Person
{
    private String name;
    private int age;

    public Person(String name, int age)
    {
        this.name = name;
        this.age = age;
    }

    public String getName()
    {
        return name;
    }

    public int getAge()
    {
        return age;
    }
}
